{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import geopandas as gpd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from shapely.geometry import Point"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 构建一万个点"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "parr = [Point(random.uniform(50,135),\n",
    "           random.uniform(18,53)) for i in range(10000)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<shapely.geometry.point.Point at 0x12a14b89358>,\n",
       " <shapely.geometry.point.Point at 0x12a14b893c8>,\n",
       " <shapely.geometry.point.Point at 0x12a14b89390>,\n",
       " <shapely.geometry.point.Point at 0x12a14b89400>,\n",
       " <shapely.geometry.point.Point at 0x12a14b894e0>,\n",
       " <shapely.geometry.point.Point at 0x12a14b89518>,\n",
       " <shapely.geometry.point.Point at 0x12a14b89550>,\n",
       " <shapely.geometry.point.Point at 0x12a14b89588>,\n",
       " <shapely.geometry.point.Point at 0x12a14b895c0>,\n",
       " <shapely.geometry.point.Point at 0x12a14b895f8>]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "parr[:10]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 利用GeoPandas直接读取shp文件，获得一个DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "cnpd = gpd.GeoDataFrame.from_file(\"./data/cn.shp\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>FIRST_NAME</th>\n",
       "      <th>Code</th>\n",
       "      <th>AREA</th>\n",
       "      <th>Pop_2009</th>\n",
       "      <th>Pop_2005</th>\n",
       "      <th>Pop_2000</th>\n",
       "      <th>Pop_1999</th>\n",
       "      <th>Pop_1995</th>\n",
       "      <th>Pop_1990</th>\n",
       "      <th>Pop_Birth_</th>\n",
       "      <th>Pop_Death_</th>\n",
       "      <th>GDP_2009</th>\n",
       "      <th>GDP_2008</th>\n",
       "      <th>GDP_2007</th>\n",
       "      <th>GDP_2006</th>\n",
       "      <th>GDP_2005</th>\n",
       "      <th>CPI_2009</th>\n",
       "      <th>CATEGORIES</th>\n",
       "      <th>geometry</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>北京</td>\n",
       "      <td>110000</td>\n",
       "      <td>1.634556e+10</td>\n",
       "      <td>1755.0000</td>\n",
       "      <td>1538.0</td>\n",
       "      <td>1382.0</td>\n",
       "      <td>1257.0</td>\n",
       "      <td>1251.0</td>\n",
       "      <td>1081.9407</td>\n",
       "      <td>8.06</td>\n",
       "      <td>5.12</td>\n",
       "      <td>12153.03</td>\n",
       "      <td>11115.00</td>\n",
       "      <td>9846.81</td>\n",
       "      <td>8117.78</td>\n",
       "      <td>6969.52</td>\n",
       "      <td>22154.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>POLYGON ((117.2016357350001 40.07728517500004,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>天津</td>\n",
       "      <td>120000</td>\n",
       "      <td>1.166096e+10</td>\n",
       "      <td>1228.1600</td>\n",
       "      <td>1043.0</td>\n",
       "      <td>1001.0</td>\n",
       "      <td>959.0</td>\n",
       "      <td>942.0</td>\n",
       "      <td>878.5402</td>\n",
       "      <td>8.30</td>\n",
       "      <td>6.23</td>\n",
       "      <td>7521.85</td>\n",
       "      <td>6719.01</td>\n",
       "      <td>5252.76</td>\n",
       "      <td>4462.74</td>\n",
       "      <td>3905.64</td>\n",
       "      <td>15149.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>POLYGON ((117.7909395950001 39.99978332000006,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>山西</td>\n",
       "      <td>140000</td>\n",
       "      <td>1.572718e+11</td>\n",
       "      <td>3427.3600</td>\n",
       "      <td>3355.0</td>\n",
       "      <td>3297.0</td>\n",
       "      <td>3204.0</td>\n",
       "      <td>3077.0</td>\n",
       "      <td>2875.9014</td>\n",
       "      <td>10.87</td>\n",
       "      <td>6.12</td>\n",
       "      <td>7358.31</td>\n",
       "      <td>7315.40</td>\n",
       "      <td>6024.45</td>\n",
       "      <td>4878.61</td>\n",
       "      <td>4230.53</td>\n",
       "      <td>6854.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>POLYGON ((114.3745051850001 40.36313191000005,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>辽宁</td>\n",
       "      <td>210000</td>\n",
       "      <td>1.450149e+11</td>\n",
       "      <td>4319.0000</td>\n",
       "      <td>4221.0</td>\n",
       "      <td>4238.0</td>\n",
       "      <td>4171.0</td>\n",
       "      <td>4092.0</td>\n",
       "      <td>3945.9697</td>\n",
       "      <td>6.06</td>\n",
       "      <td>6.15</td>\n",
       "      <td>15212.49</td>\n",
       "      <td>13668.58</td>\n",
       "      <td>11164.30</td>\n",
       "      <td>9304.52</td>\n",
       "      <td>8047.26</td>\n",
       "      <td>10848.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>POLYGON ((124.3721902000001 42.87992949500006,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>吉林</td>\n",
       "      <td>220000</td>\n",
       "      <td>1.917756e+11</td>\n",
       "      <td>2739.5500</td>\n",
       "      <td>2716.0</td>\n",
       "      <td>2728.0</td>\n",
       "      <td>2658.0</td>\n",
       "      <td>2592.0</td>\n",
       "      <td>2465.8721</td>\n",
       "      <td>6.69</td>\n",
       "      <td>6.09</td>\n",
       "      <td>7278.75</td>\n",
       "      <td>6426.10</td>\n",
       "      <td>5284.69</td>\n",
       "      <td>4275.12</td>\n",
       "      <td>3620.27</td>\n",
       "      <td>8410.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>POLYGON ((124.0338681500001 46.01935078000002,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>黑龙江</td>\n",
       "      <td>230000</td>\n",
       "      <td>4.499062e+11</td>\n",
       "      <td>3826.0000</td>\n",
       "      <td>3820.0</td>\n",
       "      <td>3689.0</td>\n",
       "      <td>3792.0</td>\n",
       "      <td>3701.0</td>\n",
       "      <td>3521.4873</td>\n",
       "      <td>7.48</td>\n",
       "      <td>5.33</td>\n",
       "      <td>8587.00</td>\n",
       "      <td>8314.37</td>\n",
       "      <td>7104.00</td>\n",
       "      <td>6211.80</td>\n",
       "      <td>5513.70</td>\n",
       "      <td>7737.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>POLYGON ((123.4345516750001 53.53447756500003,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>上海</td>\n",
       "      <td>310000</td>\n",
       "      <td>5.255602e+09</td>\n",
       "      <td>1921.0000</td>\n",
       "      <td>1778.0</td>\n",
       "      <td>1674.0</td>\n",
       "      <td>1474.0</td>\n",
       "      <td>1415.0</td>\n",
       "      <td>1334.1896</td>\n",
       "      <td>8.64</td>\n",
       "      <td>7.05</td>\n",
       "      <td>15046.45</td>\n",
       "      <td>14069.86</td>\n",
       "      <td>12494.01</td>\n",
       "      <td>10572.24</td>\n",
       "      <td>9247.66</td>\n",
       "      <td>29572.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>POLYGON ((121.741822035 30.85228484000004, 121...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>江苏</td>\n",
       "      <td>320000</td>\n",
       "      <td>1.003209e+11</td>\n",
       "      <td>7725.0000</td>\n",
       "      <td>7475.0</td>\n",
       "      <td>7438.0</td>\n",
       "      <td>7213.0</td>\n",
       "      <td>7066.0</td>\n",
       "      <td>6705.6519</td>\n",
       "      <td>9.55</td>\n",
       "      <td>6.56</td>\n",
       "      <td>34457.30</td>\n",
       "      <td>30981.98</td>\n",
       "      <td>26018.48</td>\n",
       "      <td>21742.05</td>\n",
       "      <td>18598.69</td>\n",
       "      <td>11993.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>POLYGON ((119.7877984200001 34.48132396500006,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>浙江</td>\n",
       "      <td>330000</td>\n",
       "      <td>1.009434e+11</td>\n",
       "      <td>5180.0000</td>\n",
       "      <td>4898.0</td>\n",
       "      <td>4677.0</td>\n",
       "      <td>4475.0</td>\n",
       "      <td>4319.0</td>\n",
       "      <td>4144.5930</td>\n",
       "      <td>10.22</td>\n",
       "      <td>6.75</td>\n",
       "      <td>22990.35</td>\n",
       "      <td>21462.69</td>\n",
       "      <td>18753.73</td>\n",
       "      <td>15718.47</td>\n",
       "      <td>13417.68</td>\n",
       "      <td>15790.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>POLYGON ((120.12826222 30.94705077500004, 120....</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>安徽</td>\n",
       "      <td>340000</td>\n",
       "      <td>1.409513e+11</td>\n",
       "      <td>6131.0000</td>\n",
       "      <td>6120.0</td>\n",
       "      <td>5986.0</td>\n",
       "      <td>6237.0</td>\n",
       "      <td>6013.0</td>\n",
       "      <td>5618.0813</td>\n",
       "      <td>13.07</td>\n",
       "      <td>6.41</td>\n",
       "      <td>10062.82</td>\n",
       "      <td>8851.66</td>\n",
       "      <td>7360.92</td>\n",
       "      <td>6112.50</td>\n",
       "      <td>5350.17</td>\n",
       "      <td>6829.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>POLYGON ((118.1817489250001 33.74424813500008,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>福建</td>\n",
       "      <td>350000</td>\n",
       "      <td>1.222371e+11</td>\n",
       "      <td>3627.0000</td>\n",
       "      <td>3535.0</td>\n",
       "      <td>3471.0</td>\n",
       "      <td>3316.0</td>\n",
       "      <td>3237.0</td>\n",
       "      <td>3004.8224</td>\n",
       "      <td>12.20</td>\n",
       "      <td>5.90</td>\n",
       "      <td>12236.53</td>\n",
       "      <td>10823.01</td>\n",
       "      <td>9248.53</td>\n",
       "      <td>7583.85</td>\n",
       "      <td>6554.69</td>\n",
       "      <td>10950.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>POLYGON ((120.360695272 27.23884865000002, 120...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>江西</td>\n",
       "      <td>360000</td>\n",
       "      <td>1.667767e+11</td>\n",
       "      <td>4432.1581</td>\n",
       "      <td>4311.0</td>\n",
       "      <td>4140.0</td>\n",
       "      <td>4231.0</td>\n",
       "      <td>4063.0</td>\n",
       "      <td>3771.0281</td>\n",
       "      <td>13.87</td>\n",
       "      <td>7.28</td>\n",
       "      <td>7655.18</td>\n",
       "      <td>6971.05</td>\n",
       "      <td>5800.25</td>\n",
       "      <td>4820.53</td>\n",
       "      <td>4056.76</td>\n",
       "      <td>6229.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>POLYGON ((116.258453848 29.78406868300004, 116...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>山东</td>\n",
       "      <td>370000</td>\n",
       "      <td>1.542384e+11</td>\n",
       "      <td>9470.3000</td>\n",
       "      <td>9248.0</td>\n",
       "      <td>9079.0</td>\n",
       "      <td>8883.0</td>\n",
       "      <td>8705.0</td>\n",
       "      <td>8439.2827</td>\n",
       "      <td>11.70</td>\n",
       "      <td>6.47</td>\n",
       "      <td>33896.65</td>\n",
       "      <td>30933.28</td>\n",
       "      <td>25776.91</td>\n",
       "      <td>21900.19</td>\n",
       "      <td>18366.87</td>\n",
       "      <td>10494.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>POLYGON ((122.2141180760001 36.90791152500003,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>河南</td>\n",
       "      <td>410000</td>\n",
       "      <td>1.650694e+11</td>\n",
       "      <td>9487.0000</td>\n",
       "      <td>9380.0</td>\n",
       "      <td>9256.0</td>\n",
       "      <td>9387.0</td>\n",
       "      <td>9100.0</td>\n",
       "      <td>8550.9535</td>\n",
       "      <td>11.45</td>\n",
       "      <td>6.28</td>\n",
       "      <td>19480.46</td>\n",
       "      <td>18018.53</td>\n",
       "      <td>15012.46</td>\n",
       "      <td>12362.79</td>\n",
       "      <td>10587.42</td>\n",
       "      <td>6607.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>POLYGON ((114.523150095 36.17461179500003, 114...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>湖北</td>\n",
       "      <td>420000</td>\n",
       "      <td>1.865180e+11</td>\n",
       "      <td>5720.0000</td>\n",
       "      <td>5710.0</td>\n",
       "      <td>6028.0</td>\n",
       "      <td>5938.0</td>\n",
       "      <td>5772.0</td>\n",
       "      <td>5396.9210</td>\n",
       "      <td>9.48</td>\n",
       "      <td>6.91</td>\n",
       "      <td>12961.10</td>\n",
       "      <td>11328.89</td>\n",
       "      <td>9333.40</td>\n",
       "      <td>7617.47</td>\n",
       "      <td>6590.19</td>\n",
       "      <td>7791.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>POLYGON ((109.9815026400001 33.20028491500005,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>湖南</td>\n",
       "      <td>430000</td>\n",
       "      <td>2.118197e+11</td>\n",
       "      <td>6406.0000</td>\n",
       "      <td>6326.0</td>\n",
       "      <td>6440.0</td>\n",
       "      <td>6532.0</td>\n",
       "      <td>6392.0</td>\n",
       "      <td>6065.9754</td>\n",
       "      <td>13.05</td>\n",
       "      <td>7.15</td>\n",
       "      <td>13059.69</td>\n",
       "      <td>11555.00</td>\n",
       "      <td>9439.60</td>\n",
       "      <td>7688.67</td>\n",
       "      <td>6596.10</td>\n",
       "      <td>7929.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>POLYGON ((111.5482482100001 29.89753172500008,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>广东</td>\n",
       "      <td>440000</td>\n",
       "      <td>1.760488e+11</td>\n",
       "      <td>9638.0000</td>\n",
       "      <td>9194.0</td>\n",
       "      <td>8642.0</td>\n",
       "      <td>7270.0</td>\n",
       "      <td>6868.0</td>\n",
       "      <td>6282.9236</td>\n",
       "      <td>11.78</td>\n",
       "      <td>5.70</td>\n",
       "      <td>39482.56</td>\n",
       "      <td>36796.71</td>\n",
       "      <td>31777.01</td>\n",
       "      <td>26587.76</td>\n",
       "      <td>22557.37</td>\n",
       "      <td>15291.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>POLYGON ((114.2598675200001 25.29303317500006,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>广西</td>\n",
       "      <td>450000</td>\n",
       "      <td>2.351492e+11</td>\n",
       "      <td>4856.0000</td>\n",
       "      <td>4660.0</td>\n",
       "      <td>4489.0</td>\n",
       "      <td>4713.0</td>\n",
       "      <td>4543.0</td>\n",
       "      <td>4224.5765</td>\n",
       "      <td>14.17</td>\n",
       "      <td>6.53</td>\n",
       "      <td>7759.16</td>\n",
       "      <td>7021.00</td>\n",
       "      <td>5823.41</td>\n",
       "      <td>4746.16</td>\n",
       "      <td>3984.10</td>\n",
       "      <td>6893.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>POLYGON ((111.2781950150001 26.27176769500005,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>海南</td>\n",
       "      <td>460000</td>\n",
       "      <td>3.391312e+10</td>\n",
       "      <td>864.0700</td>\n",
       "      <td>828.0</td>\n",
       "      <td>787.0</td>\n",
       "      <td>762.0</td>\n",
       "      <td>724.0</td>\n",
       "      <td>655.7482</td>\n",
       "      <td>14.66</td>\n",
       "      <td>5.61</td>\n",
       "      <td>1654.21</td>\n",
       "      <td>1503.06</td>\n",
       "      <td>1254.17</td>\n",
       "      <td>1044.91</td>\n",
       "      <td>897.99</td>\n",
       "      <td>6695.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>POLYGON ((111.0150104200001 19.64300672000007,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>重庆</td>\n",
       "      <td>500000</td>\n",
       "      <td>8.412664e+06</td>\n",
       "      <td>2859.0000</td>\n",
       "      <td>2798.0</td>\n",
       "      <td>3090.0</td>\n",
       "      <td>3075.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2886.0000</td>\n",
       "      <td>9.90</td>\n",
       "      <td>0.00</td>\n",
       "      <td>6530.01</td>\n",
       "      <td>5793.66</td>\n",
       "      <td>4676.13</td>\n",
       "      <td>3907.23</td>\n",
       "      <td>3467.72</td>\n",
       "      <td>8308.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>POLYGON ((109.7289664200001 31.69205180000006,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>四川</td>\n",
       "      <td>510000</td>\n",
       "      <td>5.635428e+11</td>\n",
       "      <td>8185.0000</td>\n",
       "      <td>8212.0</td>\n",
       "      <td>8329.0</td>\n",
       "      <td>8550.0</td>\n",
       "      <td>11325.0</td>\n",
       "      <td>7836.0000</td>\n",
       "      <td>9.15</td>\n",
       "      <td>7.21</td>\n",
       "      <td>14151.28</td>\n",
       "      <td>12601.23</td>\n",
       "      <td>10562.39</td>\n",
       "      <td>8690.24</td>\n",
       "      <td>7385.10</td>\n",
       "      <td>6863.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>POLYGON ((102.9111056930001 34.31395485500008,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>贵州</td>\n",
       "      <td>520000</td>\n",
       "      <td>1.756864e+11</td>\n",
       "      <td>3798.0000</td>\n",
       "      <td>3730.0</td>\n",
       "      <td>3525.0</td>\n",
       "      <td>3710.0</td>\n",
       "      <td>3508.0</td>\n",
       "      <td>3239.1066</td>\n",
       "      <td>13.65</td>\n",
       "      <td>7.60</td>\n",
       "      <td>3912.68</td>\n",
       "      <td>3561.56</td>\n",
       "      <td>2884.11</td>\n",
       "      <td>2338.98</td>\n",
       "      <td>2005.42</td>\n",
       "      <td>5044.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>POLYGON ((108.57061064 28.53106248500006, 108....</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>云南</td>\n",
       "      <td>530000</td>\n",
       "      <td>3.837339e+11</td>\n",
       "      <td>4571.0000</td>\n",
       "      <td>4450.0</td>\n",
       "      <td>4288.0</td>\n",
       "      <td>4192.0</td>\n",
       "      <td>3990.0</td>\n",
       "      <td>3697.2610</td>\n",
       "      <td>12.53</td>\n",
       "      <td>8.03</td>\n",
       "      <td>6169.75</td>\n",
       "      <td>5692.12</td>\n",
       "      <td>4772.52</td>\n",
       "      <td>3988.14</td>\n",
       "      <td>3461.73</td>\n",
       "      <td>5926.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>POLYGON ((99.35850006000004 28.19022834500004,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>西藏</td>\n",
       "      <td>540000</td>\n",
       "      <td>1.205060e+12</td>\n",
       "      <td>290.0300</td>\n",
       "      <td>277.0</td>\n",
       "      <td>262.0</td>\n",
       "      <td>256.0</td>\n",
       "      <td>240.0</td>\n",
       "      <td>219.6010</td>\n",
       "      <td>15.31</td>\n",
       "      <td>8.80</td>\n",
       "      <td>441.36</td>\n",
       "      <td>394.85</td>\n",
       "      <td>341.43</td>\n",
       "      <td>290.76</td>\n",
       "      <td>248.80</td>\n",
       "      <td>4060.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>POLYGON ((88.55384512000006 36.45706717500008,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>陕西</td>\n",
       "      <td>610000</td>\n",
       "      <td>2.060384e+11</td>\n",
       "      <td>3772.0000</td>\n",
       "      <td>3720.0</td>\n",
       "      <td>3605.0</td>\n",
       "      <td>3618.0</td>\n",
       "      <td>3514.0</td>\n",
       "      <td>3288.2403</td>\n",
       "      <td>10.24</td>\n",
       "      <td>6.57</td>\n",
       "      <td>8169.80</td>\n",
       "      <td>7314.58</td>\n",
       "      <td>5757.29</td>\n",
       "      <td>4743.61</td>\n",
       "      <td>3933.72</td>\n",
       "      <td>7069.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>POLYGON ((110.8688176050001 38.48005607000005,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>青海</td>\n",
       "      <td>630000</td>\n",
       "      <td>7.171531e+11</td>\n",
       "      <td>557.3000</td>\n",
       "      <td>543.0</td>\n",
       "      <td>518.0</td>\n",
       "      <td>510.0</td>\n",
       "      <td>481.0</td>\n",
       "      <td>445.6946</td>\n",
       "      <td>14.51</td>\n",
       "      <td>6.89</td>\n",
       "      <td>1081.27</td>\n",
       "      <td>1018.62</td>\n",
       "      <td>797.35</td>\n",
       "      <td>648.50</td>\n",
       "      <td>543.32</td>\n",
       "      <td>6495.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>POLYGON ((98.24841866500003 38.88231427400007,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>宁夏</td>\n",
       "      <td>640000</td>\n",
       "      <td>5.049238e+10</td>\n",
       "      <td>625.2000</td>\n",
       "      <td>596.0</td>\n",
       "      <td>562.0</td>\n",
       "      <td>543.0</td>\n",
       "      <td>513.0</td>\n",
       "      <td>465.5451</td>\n",
       "      <td>14.38</td>\n",
       "      <td>5.49</td>\n",
       "      <td>1353.31</td>\n",
       "      <td>1203.92</td>\n",
       "      <td>919.11</td>\n",
       "      <td>725.90</td>\n",
       "      <td>612.61</td>\n",
       "      <td>7858.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>POLYGON ((106.9567644250001 38.12682016500003,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>新疆</td>\n",
       "      <td>650000</td>\n",
       "      <td>1.636050e+12</td>\n",
       "      <td>2158.6300</td>\n",
       "      <td>2010.0</td>\n",
       "      <td>1925.0</td>\n",
       "      <td>1774.0</td>\n",
       "      <td>1661.0</td>\n",
       "      <td>1515.5778</td>\n",
       "      <td>15.99</td>\n",
       "      <td>6.45</td>\n",
       "      <td>4277.05</td>\n",
       "      <td>4183.21</td>\n",
       "      <td>3523.16</td>\n",
       "      <td>3045.26</td>\n",
       "      <td>2604.19</td>\n",
       "      <td>5990.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>POLYGON ((88.33823817500007 48.46869103000006,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>台湾</td>\n",
       "      <td>710000</td>\n",
       "      <td>3.588350e+10</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>POLYGON ((120.8952835700001 22.13908907000007,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>内蒙古</td>\n",
       "      <td>150000</td>\n",
       "      <td>1.147320e+12</td>\n",
       "      <td>2422.0700</td>\n",
       "      <td>2386.0</td>\n",
       "      <td>2376.0</td>\n",
       "      <td>2362.0</td>\n",
       "      <td>2284.0</td>\n",
       "      <td>2145.6798</td>\n",
       "      <td>9.57</td>\n",
       "      <td>6.70</td>\n",
       "      <td>9740.25</td>\n",
       "      <td>8496.20</td>\n",
       "      <td>6423.18</td>\n",
       "      <td>4944.25</td>\n",
       "      <td>3905.03</td>\n",
       "      <td>9668.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>POLYGON ((121.4456873900001 52.73911163000008,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>甘肃</td>\n",
       "      <td>620000</td>\n",
       "      <td>4.043729e+11</td>\n",
       "      <td>2635.4600</td>\n",
       "      <td>2594.0</td>\n",
       "      <td>2562.0</td>\n",
       "      <td>2543.0</td>\n",
       "      <td>2438.0</td>\n",
       "      <td>2237.1141</td>\n",
       "      <td>13.32</td>\n",
       "      <td>6.49</td>\n",
       "      <td>3387.56</td>\n",
       "      <td>3166.82</td>\n",
       "      <td>2702.40</td>\n",
       "      <td>2276.70</td>\n",
       "      <td>1933.98</td>\n",
       "      <td>5284.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>POLYGON ((97.67918722000007 41.94014592500002,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>河北</td>\n",
       "      <td>130000</td>\n",
       "      <td>1.855880e+11</td>\n",
       "      <td>7034.4000</td>\n",
       "      <td>6851.0</td>\n",
       "      <td>6744.0</td>\n",
       "      <td>6614.0</td>\n",
       "      <td>6437.0</td>\n",
       "      <td>6108.2439</td>\n",
       "      <td>12.93</td>\n",
       "      <td>6.32</td>\n",
       "      <td>17235.48</td>\n",
       "      <td>16011.97</td>\n",
       "      <td>13607.32</td>\n",
       "      <td>11467.60</td>\n",
       "      <td>10012.11</td>\n",
       "      <td>7193.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>(POLYGON ((118.9123335106403 39.12308411298147...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   FIRST_NAME    Code          AREA   Pop_2009  Pop_2005  Pop_2000  Pop_1999  \\\n",
       "0          北京  110000  1.634556e+10  1755.0000    1538.0    1382.0    1257.0   \n",
       "1          天津  120000  1.166096e+10  1228.1600    1043.0    1001.0     959.0   \n",
       "2          山西  140000  1.572718e+11  3427.3600    3355.0    3297.0    3204.0   \n",
       "3          辽宁  210000  1.450149e+11  4319.0000    4221.0    4238.0    4171.0   \n",
       "4          吉林  220000  1.917756e+11  2739.5500    2716.0    2728.0    2658.0   \n",
       "5         黑龙江  230000  4.499062e+11  3826.0000    3820.0    3689.0    3792.0   \n",
       "6          上海  310000  5.255602e+09  1921.0000    1778.0    1674.0    1474.0   \n",
       "7          江苏  320000  1.003209e+11  7725.0000    7475.0    7438.0    7213.0   \n",
       "8          浙江  330000  1.009434e+11  5180.0000    4898.0    4677.0    4475.0   \n",
       "9          安徽  340000  1.409513e+11  6131.0000    6120.0    5986.0    6237.0   \n",
       "10         福建  350000  1.222371e+11  3627.0000    3535.0    3471.0    3316.0   \n",
       "11         江西  360000  1.667767e+11  4432.1581    4311.0    4140.0    4231.0   \n",
       "12         山东  370000  1.542384e+11  9470.3000    9248.0    9079.0    8883.0   \n",
       "13         河南  410000  1.650694e+11  9487.0000    9380.0    9256.0    9387.0   \n",
       "14         湖北  420000  1.865180e+11  5720.0000    5710.0    6028.0    5938.0   \n",
       "15         湖南  430000  2.118197e+11  6406.0000    6326.0    6440.0    6532.0   \n",
       "16         广东  440000  1.760488e+11  9638.0000    9194.0    8642.0    7270.0   \n",
       "17         广西  450000  2.351492e+11  4856.0000    4660.0    4489.0    4713.0   \n",
       "18         海南  460000  3.391312e+10   864.0700     828.0     787.0     762.0   \n",
       "19         重庆  500000  8.412664e+06  2859.0000    2798.0    3090.0    3075.0   \n",
       "20         四川  510000  5.635428e+11  8185.0000    8212.0    8329.0    8550.0   \n",
       "21         贵州  520000  1.756864e+11  3798.0000    3730.0    3525.0    3710.0   \n",
       "22         云南  530000  3.837339e+11  4571.0000    4450.0    4288.0    4192.0   \n",
       "23         西藏  540000  1.205060e+12   290.0300     277.0     262.0     256.0   \n",
       "24         陕西  610000  2.060384e+11  3772.0000    3720.0    3605.0    3618.0   \n",
       "25         青海  630000  7.171531e+11   557.3000     543.0     518.0     510.0   \n",
       "26         宁夏  640000  5.049238e+10   625.2000     596.0     562.0     543.0   \n",
       "27         新疆  650000  1.636050e+12  2158.6300    2010.0    1925.0    1774.0   \n",
       "28         台湾  710000  3.588350e+10     0.0000       0.0       0.0       0.0   \n",
       "29        内蒙古  150000  1.147320e+12  2422.0700    2386.0    2376.0    2362.0   \n",
       "30         甘肃  620000  4.043729e+11  2635.4600    2594.0    2562.0    2543.0   \n",
       "31         河北  130000  1.855880e+11  7034.4000    6851.0    6744.0    6614.0   \n",
       "\n",
       "    Pop_1995   Pop_1990  Pop_Birth_  Pop_Death_  GDP_2009  GDP_2008  GDP_2007  \\\n",
       "0     1251.0  1081.9407        8.06        5.12  12153.03  11115.00   9846.81   \n",
       "1      942.0   878.5402        8.30        6.23   7521.85   6719.01   5252.76   \n",
       "2     3077.0  2875.9014       10.87        6.12   7358.31   7315.40   6024.45   \n",
       "3     4092.0  3945.9697        6.06        6.15  15212.49  13668.58  11164.30   \n",
       "4     2592.0  2465.8721        6.69        6.09   7278.75   6426.10   5284.69   \n",
       "5     3701.0  3521.4873        7.48        5.33   8587.00   8314.37   7104.00   \n",
       "6     1415.0  1334.1896        8.64        7.05  15046.45  14069.86  12494.01   \n",
       "7     7066.0  6705.6519        9.55        6.56  34457.30  30981.98  26018.48   \n",
       "8     4319.0  4144.5930       10.22        6.75  22990.35  21462.69  18753.73   \n",
       "9     6013.0  5618.0813       13.07        6.41  10062.82   8851.66   7360.92   \n",
       "10    3237.0  3004.8224       12.20        5.90  12236.53  10823.01   9248.53   \n",
       "11    4063.0  3771.0281       13.87        7.28   7655.18   6971.05   5800.25   \n",
       "12    8705.0  8439.2827       11.70        6.47  33896.65  30933.28  25776.91   \n",
       "13    9100.0  8550.9535       11.45        6.28  19480.46  18018.53  15012.46   \n",
       "14    5772.0  5396.9210        9.48        6.91  12961.10  11328.89   9333.40   \n",
       "15    6392.0  6065.9754       13.05        7.15  13059.69  11555.00   9439.60   \n",
       "16    6868.0  6282.9236       11.78        5.70  39482.56  36796.71  31777.01   \n",
       "17    4543.0  4224.5765       14.17        6.53   7759.16   7021.00   5823.41   \n",
       "18     724.0   655.7482       14.66        5.61   1654.21   1503.06   1254.17   \n",
       "19       0.0  2886.0000        9.90        0.00   6530.01   5793.66   4676.13   \n",
       "20   11325.0  7836.0000        9.15        7.21  14151.28  12601.23  10562.39   \n",
       "21    3508.0  3239.1066       13.65        7.60   3912.68   3561.56   2884.11   \n",
       "22    3990.0  3697.2610       12.53        8.03   6169.75   5692.12   4772.52   \n",
       "23     240.0   219.6010       15.31        8.80    441.36    394.85    341.43   \n",
       "24    3514.0  3288.2403       10.24        6.57   8169.80   7314.58   5757.29   \n",
       "25     481.0   445.6946       14.51        6.89   1081.27   1018.62    797.35   \n",
       "26     513.0   465.5451       14.38        5.49   1353.31   1203.92    919.11   \n",
       "27    1661.0  1515.5778       15.99        6.45   4277.05   4183.21   3523.16   \n",
       "28       0.0     0.0000        0.00        0.00      0.00      0.00      0.00   \n",
       "29    2284.0  2145.6798        9.57        6.70   9740.25   8496.20   6423.18   \n",
       "30    2438.0  2237.1141       13.32        6.49   3387.56   3166.82   2702.40   \n",
       "31    6437.0  6108.2439       12.93        6.32  17235.48  16011.97  13607.32   \n",
       "\n",
       "    GDP_2006  GDP_2005  CPI_2009  CATEGORIES  \\\n",
       "0    8117.78   6969.52   22154.0         1.0   \n",
       "1    4462.74   3905.64   15149.0         1.0   \n",
       "2    4878.61   4230.53    6854.0         1.0   \n",
       "3    9304.52   8047.26   10848.0         1.0   \n",
       "4    4275.12   3620.27    8410.0         1.0   \n",
       "5    6211.80   5513.70    7737.0         1.0   \n",
       "6   10572.24   9247.66   29572.0         2.0   \n",
       "7   21742.05  18598.69   11993.0         2.0   \n",
       "8   15718.47  13417.68   15790.0         2.0   \n",
       "9    6112.50   5350.17    6829.0         2.0   \n",
       "10   7583.85   6554.69   10950.0         2.0   \n",
       "11   4820.53   4056.76    6229.0         2.0   \n",
       "12  21900.19  18366.87   10494.0         2.0   \n",
       "13  12362.79  10587.42    6607.0         2.0   \n",
       "14   7617.47   6590.19    7791.0         3.0   \n",
       "15   7688.67   6596.10    7929.0         3.0   \n",
       "16  26587.76  22557.37   15291.0         3.0   \n",
       "17   4746.16   3984.10    6893.0         3.0   \n",
       "18   1044.91    897.99    6695.0         3.0   \n",
       "19   3907.23   3467.72    8308.0         3.0   \n",
       "20   8690.24   7385.10    6863.0         3.0   \n",
       "21   2338.98   2005.42    5044.0         3.0   \n",
       "22   3988.14   3461.73    5926.0         4.0   \n",
       "23    290.76    248.80    4060.0         4.0   \n",
       "24   4743.61   3933.72    7069.0         4.0   \n",
       "25    648.50    543.32    6495.0         4.0   \n",
       "26    725.90    612.61    7858.0         4.0   \n",
       "27   3045.26   2604.19    5990.0         4.0   \n",
       "28      0.00      0.00       0.0         4.0   \n",
       "29   4944.25   3905.03    9668.0         1.0   \n",
       "30   2276.70   1933.98    5284.0         4.0   \n",
       "31  11467.60  10012.11    7193.0         1.0   \n",
       "\n",
       "                                             geometry  \n",
       "0   POLYGON ((117.2016357350001 40.07728517500004,...  \n",
       "1   POLYGON ((117.7909395950001 39.99978332000006,...  \n",
       "2   POLYGON ((114.3745051850001 40.36313191000005,...  \n",
       "3   POLYGON ((124.3721902000001 42.87992949500006,...  \n",
       "4   POLYGON ((124.0338681500001 46.01935078000002,...  \n",
       "5   POLYGON ((123.4345516750001 53.53447756500003,...  \n",
       "6   POLYGON ((121.741822035 30.85228484000004, 121...  \n",
       "7   POLYGON ((119.7877984200001 34.48132396500006,...  \n",
       "8   POLYGON ((120.12826222 30.94705077500004, 120....  \n",
       "9   POLYGON ((118.1817489250001 33.74424813500008,...  \n",
       "10  POLYGON ((120.360695272 27.23884865000002, 120...  \n",
       "11  POLYGON ((116.258453848 29.78406868300004, 116...  \n",
       "12  POLYGON ((122.2141180760001 36.90791152500003,...  \n",
       "13  POLYGON ((114.523150095 36.17461179500003, 114...  \n",
       "14  POLYGON ((109.9815026400001 33.20028491500005,...  \n",
       "15  POLYGON ((111.5482482100001 29.89753172500008,...  \n",
       "16  POLYGON ((114.2598675200001 25.29303317500006,...  \n",
       "17  POLYGON ((111.2781950150001 26.27176769500005,...  \n",
       "18  POLYGON ((111.0150104200001 19.64300672000007,...  \n",
       "19  POLYGON ((109.7289664200001 31.69205180000006,...  \n",
       "20  POLYGON ((102.9111056930001 34.31395485500008,...  \n",
       "21  POLYGON ((108.57061064 28.53106248500006, 108....  \n",
       "22  POLYGON ((99.35850006000004 28.19022834500004,...  \n",
       "23  POLYGON ((88.55384512000006 36.45706717500008,...  \n",
       "24  POLYGON ((110.8688176050001 38.48005607000005,...  \n",
       "25  POLYGON ((98.24841866500003 38.88231427400007,...  \n",
       "26  POLYGON ((106.9567644250001 38.12682016500003,...  \n",
       "27  POLYGON ((88.33823817500007 48.46869103000006,...  \n",
       "28  POLYGON ((120.8952835700001 22.13908907000007,...  \n",
       "29  POLYGON ((121.4456873900001 52.73911163000008,...  \n",
       "30  POLYGON ((97.67918722000007 41.94014592500002,...  \n",
       "31  (POLYGON ((118.9123335106403 39.12308411298147...  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cnpd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Series([], )'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cnpd[cnpd[\"geometry\"].intersects(parr[0])][\"FIRST_NAME\"].to_string(index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 测试一下，用点去查询这些面"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0:00:03.200447\n"
     ]
    }
   ],
   "source": [
    "s = datetime.datetime.now()\n",
    "for p in parr:\n",
    "    cnpd[\"geometry\"].intersects(p)\n",
    "print(datetime.datetime.now()-s)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 构建一个空间索引，再来试试"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "spatial_index = cnpd.sindex"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "ls = list(spatial_index.intersection(parr[0].bounds))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "pm = cnpd.iloc[ls]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: []\n",
       "Index: []"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pm[pm.intersects(p)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 利用空间索引进行1000次查询"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 发现一个问题，如果是点对面的查询，空间索引的效率很不明显，因为构建索引也挺花时间的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0:00:06.785890\n"
     ]
    }
   ],
   "source": [
    "s = datetime.datetime.now()\n",
    "for p in parr:\n",
    "    ls = list(spatial_index.intersection(p.bounds))\n",
    "    pm = cnpd.iloc[ls]\n",
    "    pm.intersects(p)\n",
    "print(datetime.datetime.now()-s)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 传统迭代模式"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 效率的进步还是很明显的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0:00:09.754910\n"
     ]
    }
   ],
   "source": [
    "s = datetime.datetime.now()\n",
    "for p in parr:\n",
    "    for i in range(len(cnpd)):\n",
    "        p.intersects(cnpd[\"geometry\"][i])\n",
    "print(datetime.datetime.now()-s)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 当然，如果丢弃掉所有的属性数据，就走空间，\n",
    "# 传统模式也不慢，主要是pandas的迭代本来就很强大"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 但是这种情况，就没有任何分析的意义了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0:00:02.237989\n"
     ]
    }
   ],
   "source": [
    "s = datetime.datetime.now()\n",
    "cngeo = cnpd[\"geometry\"]\n",
    "for p in parr:\n",
    "    for geo in cngeo:\n",
    "        p.intersects(geo)\n",
    "print(datetime.datetime.now()-s)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
